var e = require;
var t = module;
var o = exports;
var n,
    i = o,
    a =
        ((n = function (e, t) {
            return (n =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
                })(e, t);
        }),
        function (e, t) {
            function o() {
                this.constructor = e;
            }
            n(e, t), (e.prototype = null === t ? Object.create(t) : ((o.prototype = t.prototype), new o()));
        }),
    r = function (e, t, o, n) {
        var i,
            a = arguments.length,
            r = a < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, o)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(e, t, o, n);
        else
            for (var s = e.length - 1; s >= 0; s--)
                (i = e[s]) && (r = (a < 3 ? i(r) : a > 3 ? i(t, o, r) : i(t, o)) || r);
        return a > 3 && r && Object.defineProperty(t, o, r), r;
    };
Object.defineProperty(i, "__esModule", {value: !0});
var s = e("BehaviorTree"),
    c = e("BevNodeTerminal"),
    l = e("GameModuleView"),
    d = cc._decorator,
    u = d.ccclass,
    p =
        (d.property,
        (function (e) {
            function t() {
                var t = (null !== e && e.apply(this, arguments)) || this;
                return (t.snake = null), (t.vector = null), (t.target_pos = null), t;
            }
            return (
                a(t, e),
                (t.prototype._DoEvaluate = function (e) {
                    this.snake = e.snake;
                    var t = l.default.Insance._layer_food.getMapData(this.snake.head_pos);
                    if (!t) return !1;
                    var o = cc.v2(t.x, t.y).sub(cc.v2(this.snake.head_pos.x, this.snake.head_pos.y));
                    return (
                        (this.target_pos = cc.v3(t.x, t.y, 0)),
                        (this.vector = o.normalize()),
                        (this.is_speed = t.length > 2),
                        !!this.vector
                    );
                }),
                (t.prototype._DoEnter = function () {}),
                (t.prototype._DoExecute = function (e, t) {
                    if (null == this.vector) return s.BevRunningStatus.k_BRS_Executing;
                    (t.vector = this.vector), (t.speed = this.is_speed);
                    var o = this.snake.head_pos.sub(this.target_pos).mag();
                    return o < 5 || o > 300 || null == this.vector
                        ? s.BevRunningStatus.k_BRS_Finish
                        : s.BevRunningStatus.k_BRS_Executing;
                }),
                (t.prototype._DoExit = function () {
                    this.vector = null;
                }),
                r([u], t)
            );
        })(c.BevNodeTerminal));
i.default = p;
